<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      async function fn() {
        console.log(0)

        setTimeout(() => {
          console.log(1)
        }, 0)

        await new Promise((resolve) => {
          setTimeout(() => {
            console.log(2)
          }, 0)

          console.log(3)

          setTimeout(() => {
            console.log(4)
            resolve()
          }, 1000)

          setTimeout(() => {
            console.log(5)
          }, 0)
        })

        setTimeout(() => {
          console.log(6)
        }, 0)
        console.log(7)
      }

      fn()
    </script>
  </body>
</html>
